$('.rental-btn ul li').click(function(){
    $(this).parents('.rental-btn').find('.rental-title').text($(this).text());
});
 /*messge*/
$(".messge_nav").click(function () {
 
    $(".message_content").slideToggle();
});

$(window).scroll(function(){
   $(this).scrollTop() >1?$('.go-top').show(): $('.go-top').hide();
});
//phone
$('.nav-ico').click(function(){
    $('.col-nav ul').slideToggle();
});
//go top
$(".go-top").click(function(event){		
	event.preventDefault();
	$('html,body').animate({'scrollTop':0},600);
});
$('.products .h-478').find(".c-p").each(function(){
        var ff=$(this).text().substring(0,38);
        $(this).text(ff);
   });
////寬度變化自動刷新
//window.onresize = function(){
//    location.reload(true);
//};
 $(window).load(function(){
 
    $('.a-e-i img').each(function(){
          $(this).parent('a').css({'width':'100%','height':'100%','display': 'block','overflow':' hidden'});
            
             var  wd = $(this).parent().width();
             var  hd = $(this).parent().height();
             var  wimg_a = $(this).width();
             $(this).width("100%").end();
             var  himg_a = $(this).height();
            if(himg_a > hd){
        
                 $(this).css({"margin-top":-Math.abs(himg_a - hd)/2});
            }else if(himg_a <= hd){
                 $(this).css({"height":"100%","width":"100%"});
            }
        });
 }); 
  
 $(window).load(function(){

 $('.c-e-i img').each(function(){
      $(this).parent('a').css({'width':'100%','height':'100%','display': 'block','overflow':' hidden'});
   
             var  wd = $(this).parent().width();
             var  hd = $(this).parent().height();
             var  wimg_a = $(this).width();
             var  himg_a = $(this).height();
        
       if(wimg_a > himg_a){
        $(this).css({"height":"100%"}).end();
        var  wimg = $(this).width();
         if(wimg < wd){
             $(this).css({"width":"100%"});
         }else if(wimg > wd){
              $(this).css({"margin-left":-Math.abs((wimg - wd)/2)}); 
         } 
   }else if(wimg_a < himg_a){
      $(this).css({"width":"100%"}).end(); 
     var   himg = $(this).height();
        if(himg < hd){
             $(this).css({"height":"100%"});
         }else if(himg > hd){
             $(this).css({"margin-top":-Math.abs(himg - hd)/2});
         }
    }else if(wimg_a === himg_a){
        $(this).css({"height":"100%","width":"100%"});
    } 
  
  }); 

  }); 
//slide
    var swiper1 = new Swiper('.swiper1', {
        pagination: '.swiper-pagination1',
        nextButton: '.swiper-button-next1',
        prevButton: '.swiper-button-prev1',
        slidesPerView: 1,
        paginationClickable: true,
        spaceBetween: 30
        
    });
     var swiper2 = new Swiper('.swiper2', {
        pagination: '.swiper-pagination2',
        nextButton: '.swiper-button-next2',
        prevButton: '.swiper-button-prev2',
        paginationClickable: true,
        spaceBetween: 30
         
    });
         var swiper4 = new Swiper('.swiper4', {
        pagination: '.swiper-pagination4',
        nextButton: '.swiper-button-next4',
        prevButton: '.swiper-button-prev4',
        paginationClickable: true,
        spaceBetween: 30
         
    });
  
    if(document.body.clientWidth < 750){
  
        $('.a-e-i').addClass('c-e-i').removeClass('a-e-i');
//           var swiper3 = new Swiper('.swiper3', {
//        pagination: '.swiper-pagination3',
//        nextButton: '.swiper-button-next3',
//        prevButton: '.swiper-button-prev3',
//        slidesPerView: 1,
//        paginationClickable: true,
//        spaceBetween: 30
//         
//    }); 

}
//    else{
//             var swiper3 = new Swiper('.swiper3', {
//        pagination: '.swiper-pagination3',
//        nextButton: '.swiper-button-next3',
//        prevButton: '.swiper-button-prev3',
//        slidesPerView: 3,
//        slidesPerColumn: 2,
//        paginationClickable: true,
//        spaceBetween: 30
//         
//    });
//  
//    }
    //prettyPhoto	
$("area[rel^='prettyPhoto']").prettyPhoto();
$(".gallery:first a[rel^='prettyPhoto']").prettyPhoto({animation_speed: 'normal', theme: 'light_square', slideshow: 300, autoplay_slideshow: false});
$(".gallery:gt(0) a[rel^='prettyPhoto']").prettyPhoto({animation_speed: 'fast', slideshow: 10000, hideflash: true});
